import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {TabsPage} from './tabs.page';
import {LoginGuard} from '../guards/login.guard';
import {UserRoleGuard} from '../guards/user-role.guard';

const routes: Routes = [
  {
    path: 'tabs',
    component: TabsPage,
    children: [
      {
        path: 'home',
        children: [
          {
            path: '',
            loadChildren: '../tab/home/home.module#HomePageModule'
          }
        ]
      },
      {
        path: 'lend',
        children: [
          {
            path: '',
            loadChildren: '../tab/lend/lend.module#LendPageModule'
          }
        ]
      },
      {
        path: 'user',
        children: [
          {
            path: '',
            loadChildren: '../tab/user/user.module#UserPageModule'
          }
        ],
        canActivateChild: [
          LoginGuard, // 登录守卫LoginGuard
          UserRoleGuard // 用户角色守卫，未开通存管前往实名认证界面
        ]
      },
      {
        path: '',
        redirectTo: '/tabs/home',
        pathMatch: 'full'
      }
    ]
  },
  {
    path: '',
    redirectTo: '/tabs/home',
    pathMatch: 'full'
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class TabsPageRoutingModule {
}
